
const clearLoginStatus = () => {
  let app = getApp();
  // app.globalData.hasLogin = false;
  app.globalData.user = null;
  wx.removeStorageSync('token');
};

const checkStorageSync = key => {
  let keys = wx.getStorageInfoSync().keys;
  return keys.indexOf(key) !== -1;
}

const redirect = () => {
  let app = getApp();
  if (app.globalData.redirect) {
    var redirect = app.globalData.redirect;
    app.globalData.redirect = null;
    wx.redirectTo({ url: redirect });
  } else {
    wx.redirectTo({ url: '/pages/home/home' });
  }
}

module.exports = {
  redirect,
  checkStorageSync,
  clearLoginStatus
}
